package com.gui.windows.components;

import java.util.ArrayList;
import java.util.List;

import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

public class EditionPanel extends GenericPanel {

	//**************************************************************************************************
	//	Constructor.
	//**************************************************************************************************
	
	public EditionPanel () {
		create();
	}
	
	//**************************************************************************************************
	//	Attributes.
	//**************************************************************************************************
	
	static final long serialVersionUID = 1L;

	/** The lists containing all the possible containers of the current component.*/
	private List <String> containerList;
	
	/** To show the id of the component. Should be not editable. */
	private JTextField id;

	/** To show the name of the component. */
	private JTextField name;
	
	/** Combo box that contains the possible containers of the current component. */
	private ComboBoxAutoBinded containerSelection;
	
	/** Table that contains the info of the components contained by the current item. */
	private JTable containedTable;
	
	/** Scroll pane to show the scroll view of the containedTable. */
	private JScrollPane containedPane;
	
	// Panel dimensions.
	public static final int MINIMUM_PANEL_WIDTH 	= 120;
	public static final int MINIMUM_PANEL_HEIGHT 	= 120;
	public static final int MAXIMUM_PANEL_WIDTH		= 150;
	public static final int MAXIMUM_PANEL_HEIGHT 	= 90;
	
	// Some Strings.
	private static final String STR_ID	 = "Id";
	private static final String STR_NAME = "Namen";
	private static final String STR_ITEM_CONTAINER 	= "Container";
	private static final String STR_ITEM_CONTAINED 	= "Item selection";
	
	//**************************************************************************************************
	//	Public Methods.
	//**************************************************************************************************

	@Override
	public void update(int command) {
		
	}

	@Override
	protected void addComponents() {
		JLabel lId = new JLabel(STR_ID);
		JLabel lName = new JLabel(STR_NAME);
		JLabel lItemContainer = new JLabel(STR_ITEM_CONTAINER);
		JLabel lItemContained = new JLabel(STR_ITEM_CONTAINED);
		layout.setHorizontalGroup(
			layout.createParallelGroup()
				.add(layout.createSequentialGroup()
					.add(layout.createParallelGroup()
						.add(lId)
						.add(id))
					.add(layout.createParallelGroup()
						.add(lName)
						.add(name)))
				.add(lItemContainer)
				.add(containerSelection)
				.add(containedPane)
				.add(lItemContained)
		);
		layout.setVerticalGroup(
			layout.createSequentialGroup()
				.add(layout.createParallelGroup()
				.add(layout.createSequentialGroup()
					.add(lId)
					.add(id))
				.add(layout.createSequentialGroup()
					.add(lName)
					.add(name)))
				.add(lItemContainer)
				.add(containerSelection)
				.add(lItemContained)
				.add(containedPane)
		);
	}

	@Override
	protected void initComponents() {
		id = new JTextField();
		name = new JTextField();
		containerList = new ArrayList <String> ();
		containedTable = new JTable();
		containedPane = new JScrollPane();
		containerSelection = new ComboBoxAutoBinded(containerList);
	}

}
